module(..., package.seeall) -- 使得文件中的函数在何处都可调用
require "pins" -- 用到了pin库，该库为luatask专用库，需要进行引用
require "nvm"
require "config"

nvm.init("config.lua",true)

local solenoidValveOnState = nvm.get("solenoidValveOnState")

-- 电磁阀状态（高电平释放-电磁阀打开，低电平吸合-电磁阀关闭）

function gpioIntFnc(msg)
    log.info("testGpioSingle.gpio18IntFnc", msg, getGpio19Fnc())
    if msg == cpu.INT_GPIO_NEGEDGE then
        nvm.set("solenoidValveOnState","0")
    elseif msg == cpu.INT_GPIO_POSEDGE then
        nvm.set("solenoidValveOnState","1")
    end
end

-- 下降沿中断时：msg为cpu.INT_GPIO_POSEDGE；下降沿中断时：msg为cpu.INT_GPIO_NEGEDGE
getGpio19Fnc = pins.setup(pio.P0_19, gpioIntFnc)
